var a = require("../export.js");

getApp();

Page({
    data: {
        MyCar: [],
        sta: 0,
        data1: {},
        code_arr: []
    },
    onLoad: function(a) {
        this.getMyCar(a);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    getMyCar: function(t) {
        var n = this;
        a.requestUtil.post(a._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getMyCar.html", t, function(a) {
            if (0 == a.length) {
                var t = n.data.data1;
                t.username = "何xx", t.car_code = "豫：5867", t.car_name = "xxxxx", t.mobile = "138138138138", 
                t.city = "山西省-太原市-小店区", t.car_name = "马自达XX", t.buy_time = "20xx-xx-xx", n.setData({
                    MyCar: t,
                    code_arr: t.car_code.split("")
                });
            } else n.setData({
                MyCar: a,
                code_arr: a.car_code.split("")
            });
        }), console.log(this.data);
    },
    goAddCar: function() {
        wx.navigateTo({
            url: "/pages/car/add-car/add-car"
        });
    },
    goDelCar: function(t) {
        var n = this, o = {
            options: t,
            id: t.currentTarget.dataset.id
        };
        a.requestUtil.post(a._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/delCar.html", o, function(a) {
            n.DelCar(a);
        });
    },
    DelCar: function(a) {
        this.setData({
            MyCar: [],
            sta: 1
        }), wx.showModal({
            title: "提示",
            content: a.info,
            showCancel: !1,
            complete: function(a) {
                wx.navigateTo({
                    url: "/pages/car/my-car/my-car",
                    fail: function(a) {
                        wx.switchTab({
                            url: "/pages/car/index/index"
                        });
                    }
                });
            }
        });
    }
});